<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        ul{
            margin: 100px 200px;
        }
        li{
            text-align: center;
            line-height: 40px;
            list-style: none;
            float: left;
            width: 120px;
            height: 40px;
            border: 2px solid #bbb;
            cursor: pointer;
            user-select: none;
        }
        .red{
            background: #2ea13d;
        }
    </style>
</head>
<body>
    <ul>
        <li>首页</li>
        <li>首页</li>
        <li>首页</li>
        <li>首页</li>
        <li>首页</li>
        <li>首页</li>
    </ul>
</body>
</html>
<script>
    var lis = document.querySelectorAll('li')
    lis.forEach(function(item){
        item.onclick = function(){
            lis.forEach(function(li){
                li.classList.remove('red')
            })
            item.classList.add('red')
        }
    })
    const as = [1,2,3,4,5].map((item) =>
        item ** 2
    )
    console.log(as);
</script>